#include <Driver.h>

#include <client/dbclient.h>

//#include <iostream>

namespace{
    bool is_alive(const CExpert::DBChecker::conn_params& cp){
        try{
            mongo::DBClientConnection c(false, NULL, 1);
            if (cp.port.empty())
                c.connect(cp.host);
            else
                c.connect(mongo::HostAndPort(cp.host, atoi(cp.port.c_str())));
            return true;
        } catch (const std::exception& ex){
            return false;
        }
        return false;
    }
}
void mongo_init(){
    static int mongo_init_v = CExpert::register_driver("mongo", &is_alive);
    (void)mongo_init_v;
}

